import { ccs } from "../../util/services";
import { cardType } from "../gameType";


export default class cardClass {

    cardList: cardType[] = null;
    constructor(data?: any) {
        this.cardList = data || ccs.dataMgr.getCardByType();
    }
    //减少时间
    reduceTime() {
        this.cardList.forEach(val => {
            if(!val.have) {
                val.leftTime --;
                if(val.leftTime <= 0 ){
                    val.leftTime = 0;
                }
            }
        });
    }
    //重置考试时间
    setTime(id: string) {
        let card = this.cardList.find(val => val.id == id);
        if(card) {
            card.leftTime = card.between;
        }
    }
    getTime(id: string) {

    }
    setCardState(id: string) {
        let card: cardType = this.cardList.find(val => val.id == id);
        card.have = 1;
    }
    getCard() {
        return this.cardList.filter(val => val.type == 'card');
    }
}